package test.test.androidsocketclient;

import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import test.test.androidsocketclient.R;

//new Thread(new ClientThread()).start();
// Inflate the menu; this adds items to the action bar if it is present.
// TODO Auto-generated catch block
// TODO Auto-generated catch block
// do something
// TODO Auto-generated catch block
public class MainActivity extends Activity 
{

	
	//private String SERVER_IP = "192.168.30.177";
	

	
	private EditText ipField;
	
//	private Thread thread;
	private CallSender connection;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		
		
		
		//new Thread(new ClientThread()).start();
	}
	
	public void onConnectButtonClicked(View view)
	{
		ipField = (EditText) findViewById(R.id.ipField);
		
		connection = new CallSender(ipField.getText().toString());
		
		new Thread(connection).start();
		
		
		
	}
	
	public void onUpdateButtonClicked(View view)
	{
		connection.sendSocketCall(Command.UpdateSnippet, "");
	}
	
	public void onDisconnectButtonClicked(View view)
	{
		connection.disconnect();
	}
	
		
//	void sendSocketCall(Command command, String msg)
//	{
//		
//	}
	
}

	

